#ifndef  __RELAY_CFG_H__
#define  __RELAY_CFG_H__


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   RELAY_CFG_GLOBALS
#define  RELAY_CFG_EXT
#else
#define  RELAY_CFG_EXT  extern
#endif

/** 
  * @brief   Outputs           Port
  * EXCV-FORWARD      ------------------PB8 (O)
  * EXCV-REVESRE      ------------------PB7 (O)
  * EXCV-SW           ------------------PB6 (O)
  * EXCV2-FORWARD     ------------------PD0 (O)
  * EXCV2-REVESRE     ------------------PC12(O)
  * EXCI-FORWARD      ------------------PB4 (O)
  * EXCI-REVESRE      ------------------PB3 (O)
  * EXCI-SW           ------------------PD7 (O)
  * EXCI-FORWARD2     ------------------PD6 (O)
  * EXCI-REVESRE2     ------------------PD5 (O)
  * EXCV_VALVE        ------------------PD4 (O)
  * BUILD_VOL-FORWARD ------------------PD3 (O)
  * BUILD_VOL-REVERSE ------------------PD2 (O)
  * BUILD_VOL-SW      ------------------PD1 (O)
  * AUX_OUT1          ------------------PE0 (O)
  */
/* EXCV-FORWARD */
#define RCCPeriph_EXCV_FORWARD   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCV_FORWARD   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV_FORWARD   GPIO_Speed_50MHz
#define GPIOxPort_EXCV_FORWARD   GPIOB
#define GPIOxBitx_EXCV_FORWARD   GPIO_PIN_8
/* EXCV-REVESRE */
#define RCCPeriph_EXCV_REVESRE   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCV_REVESRE   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV_REVESRE   GPIO_Speed_50MHz
#define GPIOxPort_EXCV_REVESRE   GPIOB
#define GPIOxBitx_EXCV_REVESRE   GPIO_PIN_7
/* EXCV-SW */
#define RCCPeriph_EXCV_SW        RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCV_SW        GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV_SW        GPIO_Speed_50MHz
#define GPIOxPort_EXCV_SW        GPIOB
#define GPIOxBitx_EXCV_SW        GPIO_PIN_6

/* 原WORM_GEAR-FORWARD */
// 现EXCV2-FORWARD
#define RCCPeriph_EXCV2_FORWARD   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCV2_FORWARD   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV2_FORWARD   GPIO_Speed_50MHz
#define GPIOxPort_EXCV2_FORWARD   GPIOD
#define GPIOxBitx_EXCV2_FORWARD   GPIO_PIN_0
/* 原WORM_GEAR-REVERS */
// 现EXCV2-REVESRE
#define RCCPeriph_EXCV2_REVESRE   RCC_APB2_PERIPH_GPIOC
#define GPIOModeI_EXCV2_REVESRE   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV2_REVESRE   GPIO_Speed_50MHz
#define GPIOxPort_EXCV2_REVESRE   GPIOC
#define GPIOxBitx_EXCV2_REVESRE   GPIO_PIN_12


/* EXCI-FORWARD */
#define RCCPeriph_EXCI_FORWARD   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCI_FORWARD   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCI_FORWARD   GPIO_Speed_50MHz
#define GPIOxPort_EXCI_FORWARD   GPIOB
#define GPIOxBitx_EXCI_FORWARD   GPIO_PIN_4
/* EXCI-REVESRE */
#define RCCPeriph_EXCI_REVESRE   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCI_REVESRE   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCI_REVESRE   GPIO_Speed_50MHz
#define GPIOxPort_EXCI_REVESRE   GPIOB
#define GPIOxBitx_EXCI_REVESRE   GPIO_PIN_3                

/* EXCI-SW */
#define RCCPeriph_EXCI_SW        RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI_SW        GPIO_Mode_Out_PP
#define GPIOSpeed_EXCI_SW        GPIO_Speed_50MHz
#define GPIOxPort_EXCI_SW        GPIOD
#define GPIOxBitx_EXCI_SW        GPIO_PIN_7

/* EXCI-FORWARD2 */
#define RCCPeriph_EXCI_FORWARD2   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI_FORWARD2   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCI_FORWARD2   GPIO_Speed_50MHz
#define GPIOxPort_EXCI_FORWARD2   GPIOD
#define GPIOxBitx_EXCI_FORWARD2   GPIO_PIN_6
/* EXCI-REVESRE2 */
#define RCCPeriph_EXCI_REVESRE2   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI_REVESRE2   GPIO_Mode_Out_PP
#define GPIOSpeed_EXCI_REVESRE2   GPIO_Speed_50MHz
#define GPIOxPort_EXCI_REVESRE2   GPIOD
#define GPIOxBitx_EXCI_REVESRE2   GPIO_PIN_5

/* EXCV_VALVE */
#define RCCPeriph_EXCV_VALVE       RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCV_VALVE       GPIO_Mode_Out_PP
#define GPIOSpeed_EXCV_VALVE       GPIO_Speed_50MHz
#define GPIOxPort_EXCV_VALVE       GPIOD
#define GPIOxBitx_EXCV_VALVE       GPIO_PIN_4
// /* EXCI-SW2 */
// #define RCCPeriph_EXCI_SW2       RCC_APB2_PERIPH_GPIOD
// #define GPIOModeI_EXCI_SW2       GPIO_Mode_Out_PP
// #define GPIOSpeed_EXCI_SW2       GPIO_Speed_50MHz
// #define GPIOxPort_EXCI_SW2       GPIOD
// #define GPIOxBitx_EXCI_SW2       GPIO_PIN_4

/* BUILD_VOL-FORWARD */
#define RCCPeriph_BUILD_VOL_FOR   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_BUILD_VOL_FOR   GPIO_Mode_Out_PP
#define GPIOSpeed_BUILD_VOL_FOR   GPIO_Speed_50MHz
#define GPIOxPort_BUILD_VOL_FOR   GPIOD
#define GPIOxBitx_BUILD_VOL_FOR   GPIO_PIN_3
/* BUILD_VOL-REVERSE */
#define RCCPeriph_BUILD_VOL_REV   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_BUILD_VOL_REV   GPIO_Mode_Out_PP
#define GPIOSpeed_BUILD_VOL_REV   GPIO_Speed_50MHz
#define GPIOxPort_BUILD_VOL_REV   GPIOD
#define GPIOxBitx_BUILD_VOL_REV   GPIO_PIN_2
/* BUILD_VOL-SW */
#define RCCPeriph_BUILD_VOL_SW   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_BUILD_VOL_SW   GPIO_Mode_Out_PP
#define GPIOSpeed_BUILD_VOL_SW   GPIO_Speed_50MHz
#define GPIOxPort_BUILD_VOL_SW   GPIOD
#define GPIOxBitx_BUILD_VOL_SW   GPIO_PIN_1

/* AUX_OUT1 */
#define RCCPeriph_AUX_OUT1   RCC_APB2_PERIPH_GPIOE
#define GPIOModeI_AUX_OUT1   GPIO_Mode_Out_PP
#define GPIOSpeed_AUX_OUT1   GPIO_Speed_50MHz
#define GPIOxPort_AUX_OUT1   GPIOE
#define GPIOxBitx_AUX_OUT1   GPIO_PIN_0

typedef struct
{
  uint32_t              RCC_APB2Periph;
  GPIO_ModeType         GPIO_Mode;
  GPIO_SpeedType        GPIO_Speed;
  GPIO_Module*          GPIOx;
  uint16_t              GPIO_Pin;
} RelayCfg_TypeDef;
     
#define RelayOutOrd_EXCV_FORWARD          0
#define RelayOutOrd_EXCV_REVESRE          1
#define RelayOutOrd_EXCV_SW               2
#define RelayOutOrd_EXCV2_FORWARD         3
#define RelayOutOrd_EXCV2_REVESRE         4
#define RelayOutOrd_EXCI_FORWARD          5
#define RelayOutOrd_EXCI_REVESRE          6
#define RelayOutOrd_EXCI_SW               7
#define RelayOutOrd_EXCI_FORWARD2         8
#define RelayOutOrd_EXCI_REVESRE2         9
#define RelayOutOrd_EXCV_VALVE            10
#define RelayOutOrd_BUILD_VOL_FORWARD     11
#define RelayOutOrd_BUILD_VOL_REVERSE     12
#define RelayOutOrd_BUILD_VOL_SW          13
#define RelayOutOrd_AUX_OUT1              14
#define RelayOutputsTOTNum                (RelayOutOrd_AUX_OUT1+1)
RELAY_CFG_EXT const RelayCfg_TypeDef RelayOutCfgTable[RelayOutputsTOTNum];


/*************RelayOutput 继电器输出配置 *********/
#define RelayOutput_EXCV_FORWARD         0
#define RelayOutput_EXCV_REVESRE         1
#define RelayOutput_EXCV_SW              2
#define RelayOutput_EXCV2_FORWARD        3
#define RelayOutput_EXCV2_REVESRE        4
#define RelayOutput_EXCI_FORWARD         5
#define RelayOutput_EXCI_REVESRE         6
#define RelayOutput_EXCI_SW              7
#define RelayOutput_EXCI2_FORWARD        8
#define RelayOutput_EXCI2_REVESRE        9
#define RelayOutput_EXCV_VALVE           10
#define RelayOutput_BUILD_VOL_FORWARD    11
#define RelayOutput_BUILD_VOL_REVERSE    12
#define RelayOutput_BUILD_VOL_SW         13
#define RelayOutput_AUX_OUT1             14 //励磁电源
#define AuxiStaOrd_TOTNum                              (RelayOutput_AUX_OUT1+1)
#define InputAuxiSta_TOTByteNum                        ((AuxiStaOrd_TOTNum-1)/8+1)
RELAY_CFG_EXT uint8_t ShareBuffer_Outputs[InputAuxiSta_TOTByteNum];



 

#endif